package com.polaris.live.adapter.level

import android.view.View
import com.blankj.utilcode.util.ColorUtils
import com.polaris.live.R
import com.polaris.live.common.R.color
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterCharmTempLevelBinding
import com.polaris.live.resp.bean.LevelUpRewardBean
/**
 * MeCharmRichLevelAdapter
 *
 * @author Created by 半仙 on 2024/2/1/001 17:46
 */
class MeCharmTempLevelAdapter :
    BaseBindingAdapter<AdapterCharmTempLevelBinding, LevelUpRewardBean>() {

    private var mSelectPosition = 0
    override fun convert(
        holder: VBViewHolder<AdapterCharmTempLevelBinding>,
        item: LevelUpRewardBean,
    ) {
        holder.vb.apply {
            val position = holder.absoluteAdapterPosition
            if (position != data.size - 1) {
                rightview.visibility = View.VISIBLE
            } else {
                rightview.visibility = View.GONE
            }
            if (position == mSelectPosition) {
                tvLevel.setTextColor(ColorUtils.getColor(color.white))
                cosBack.setBackgroundColor(ColorUtils.getColor(color.color_ff93f1))
            } else {
                tvLevel.setTextColor(ColorUtils.getColor(color.color_202028))
                cosBack.setBackgroundColor(ColorUtils.getColor(R.color.color_fff4fd))
            }
            tvLevel.text = "L${item.level}"
        }
    }

    fun setSelect(position: Int) {
        mSelectPosition = position
        notifyDataSetChanged()
    }
}